package cn.edu.hunau.oop.day07;

import java.util.Objects;

/**
 * @author hb
 * @date 2025-08-12 09:52:15
 */
public class Apple {
    // 品种 ‌红富士 瑞雪 ‌红星  国光
    private String type;
    // 颜色 红色,绿色,青色
    private String color;
    // 重量 80~200
    private double weight;

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Apple apple)) return false;
        return Double.compare(weight, apple.weight) == 0 && Objects.equals(type, apple.type) && Objects.equals(color, apple.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, color, weight);
    }

    @Override
    public String toString() {
        return "Apple{" +
                "type='" + type + '\'' +
                ", color='" + color + '\'' +
                ", weight=" + weight +
                "}\n";
    }

    public Apple() {
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Apple(String type, String color, double weight) {
        this.type = type;
        this.color = color;
        this.weight = weight;
    }
}
